package ecs.dogear.app;


public class AddReplyTransaction implements Transaction {

	private int userId;
	private int replyId;
	private String commentStr;
	private int commentId;

	public AddReplyTransaction(int userId, int replyId, String commentStr,
			int commentId) {
		this.userId = userId;
		this.replyId = replyId;
		this.commentStr = commentStr;
		this.commentId = commentId;
	}

	public void execute() {
		Comment repliedComment = CommenterDatabase.getComment(commentId);
		String url = repliedComment.getUrl()+" ";
		Comment comment = new Comment(commentStr,url,replyId,userId,repliedComment.getPageTitle());
		CommenterDatabase.addComment(comment);
        CommenterDatabase.addReplyTo(commentId,replyId);
        repliedComment.addReply(comment);
	}

}
